"""
URL configuration for startdjango project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.http import HttpResponse
from django.urls import path, include
from django.urls import reverse

import book
import book.views as book_views


def index(request):
    print(reverse("book:book_str", kwargs={"book_id": "1"}))
    print(reverse("book:book_detail_query_string") + "?book_id=1&name='张三'")
    return HttpResponse("Hello world Jungle")


urlpatterns = [
    path('admin/', admin.site.urls),

    path('', index, name='index'),

    # http://127.0.0.1:8000/book?id=3
    # path('book', book_views.book_detail_query_string),
    # # #在book_id前指定参数类型有两点好处:
    # # #1、以后在浏览器中，如果book_id输入的是一个非整形，那么会出现404错误:/book/abc
    # # #2.在视图函数中，得到的book_id就是一个整形
    # # 参数类型 int
    # path('book/<int:book_id>', book_views.book_detail_path),
    # # 参数类型 str
    # path('book/str/<str:book_id>', book_views.book_str),
    # # 参数类型 slug
    # path('book/slug/<slug:book_id>', book_views.book_slug),
    # # 参数类型 uuid
    # path('book/uuid/<uuid:book_id>', book_views.book_uuid),
    #
    # # 参数类型 path
    # path('book/path/<path:book_id>', book_views.book_path),

    # 分模块
    path('book/', include('book.urls')),

    path('movie/', include('movie.urls')),
    path('home/', include('home.urls')),

    path('article/', include('article.urls')),
    path('front/', include('front.urls')),
    path('cookie/', include('cookie.urls')),
    path('csrf/', include('csrf.urls')),
]
